package com.gomyb.admin.module.user.controller;

import com.gomyb.admin.module.user.model.SysPermission;
import com.gomyb.common.base.BaseController;
import com.gomyb.common.base.BaseService;
import com.gomyb.common.page.PageResult;
import com.gomyb.result.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author <a href="mailto:hellohesir@gmail.com">Mr_He</a>
 * 2019-04-01 16:57:21
 */
@RestController
@Log4j2
@RequestMapping(value = "/sysPermission", name = "权限管理")
public class SysPermissionController extends BaseController<SysPermission, Long> {

    @Override
    @Autowired
    public void setService(BaseService<SysPermission, Long> service) {
        super.service = service;
    }

    @PostMapping(value = "/see/{id}", name = "查看")
    public Result<SysPermission> see(@PathVariable("id") Long id) {
        return super.get(id);
    }

    @PostMapping(value = "/add", name = "添加")
    public Result add(SysPermission sysPermission) {
        return super.save(sysPermission);
    }

    @PostMapping(value = "/modify", name = "修改")
    public Result modify(SysPermission sysPermission) {
        return super.update(sysPermission);
    }

    @PostMapping(value = "/list", name = "列表")
    public PageResult<SysPermission> list(HttpServletRequest request) {
        return super.findPage(request);
    }

    @PostMapping(value = "/remove", name = "删除")
    public Result remove(String ids) {
        return super.deleteAll(ids);
    }

}
